package com.ruoyi.web.open.customer;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.IpUtils;
import com.ruoyi.customer.domain.UserCustomerInfo;
import com.ruoyi.customer.service.IUserCustomerInfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@CrossOrigin("*")
@RestController
@RequestMapping("/open/customer/baseinfo")
public class UserCustomerOpenController extends BaseController {

    @Resource
    private IUserCustomerInfoService userCustomerInfoService;

    /**
     * 新增保存用户 - 客户信息
     */
    @Log(title = "用户 - 客户信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(UserCustomerInfo userCustomerInfo, HttpServletRequest httpServletRequest)
    {
        String ip = IpUtils.getIpAddr(httpServletRequest);
        userCustomerInfo.setCustomerIp(ip);
        return toAjax(userCustomerInfoService.insertUserCustomerInfo(userCustomerInfo));
    }
}
